Skip to content

Conversation

janchri
Copy link
Contributor

@janchri janchri commented Oct 7, 2025

This is a proposal to fix the issue with CONTAINER_OF dereferencing in the trigger handler (see the following issue: #97124).

With this fix, it is possible to define a custom-made

struct sensor_device {
...
struct sensor_trigger trigger;
...
}; 
struct sensor_device sdevice;

and by setting sensor_trigger_set(dev, &sdevice.trigger, handler) while initialisation, access in handler() via CONTAINER_OF to the underlying struct sdevice is granted.

fixes: #97124

ubieda
ubieda previously approved these changes Oct 7, 2025
Copy link
Member

@ubieda ubieda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@janchri janchri force-pushed the fix/icm_trigger branch 2 times, most recently from 188cad6 to 6347062 Compare October 7, 2025 19:56
@kartben
Copy link
Contributor

kartben commented Oct 8, 2025

@janchri can you please update the commit message to indicate it Fixes zephyrproject-rtos/zephyr#97124?

@janchri
Copy link
Contributor Author

janchri commented Oct 8, 2025

Do I add this in the body of the commit message?

MaureenHelm
MaureenHelm previously approved these changes Oct 8, 2025
@janchri janchri dismissed stale reviews from MaureenHelm and ubieda via 6347062 October 8, 2025 21:25
…R_OF

Allows CONTAINER_OF inside trigger handler to be used to obtain a valid
ptr to the composite struct consisting of a struct sensor_trigger trig.

Fixes zephyrproject-rtos#97124

Signed-off-by: Christoph Jans <[email protected]>
@janchri
Copy link
Contributor Author

janchri commented Oct 8, 2025

Included the fix inside the commit body message.

@janchri janchri requested review from MaureenHelm and ubieda October 8, 2025 21:33
Copy link

sonarqubecloud bot commented Oct 8, 2025

Copy link
Member

@ubieda ubieda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the commit title be one line or is it okay splitting it as it is in this PR?

@jhedberg jhedberg merged commit 22471f1 into zephyrproject-rtos:main Oct 9, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICM45686] Limiting implementation of trigger/trigger set

6 participants